// Copyright (c) [2021] [daifang]
// [Dcomponent] is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
import './index.less'
import { childrenMap } from '../util/Utils'
import { number, string, bool } from 'prop-types'
function Row(props){
    let {className, align, gutter, justify, wrap, children} = props

    return <div className={`d-row align-${align} justify-${justify} flex-${wrap||'nowarp'} ${className}`}>
        {childrenMap(children,{gutter})}
    </div>
}
function Col(props){
    let {span, children, gutter, align, justify} = props
    return<div 
            style={{width:(((span>gutter)?gutter:span)/gutter)*100 + '%'}} 
            className={`d-col align-${align} justify-${justify}`}>
        {children}
    </div>
}
Row.propTypes={
    className:string, 
    align:string, 
    gutter:number, 
    justify:string,
    wrap:bool
}
Col.propTypes={
    className:string, 
    span:number, 
    justify:string,
    align:string,
    gutter:number, 
}
Row.defaultProps={
    className:'', 
    align:'center', 
    gutter:24, 
    justify:'center',
    wrap:true
}
Col.defaultProps={
    className:'', 
    span:24, 
    justify:'center',
    align:'center'
}
export{
    Row,Col
}